package org.vogelsk.archangelsk.gui;

import org.vogelsk.archangelsk.creatures.Tank;
import org.vogelsk.archangelsk.util.Direction;

import android.graphics.Bitmap;

public class TankImage {
	
	private Bitmap facingLeftImage;
	private Bitmap facingRightImage;
	private Bitmap facingUpImage;
	private Bitmap facingDownImage;
	private Bitmap destroyedImage;

	public Bitmap getCurrentImage(Tank owner){
		if (owner.isDestroyed()){
			return destroyedImage;
		}
		
		Bitmap tankImage = null;
		
		if (owner.getDirection().equals(Direction.RIGHT)){
			tankImage = facingRightImage;
		}
		if (owner.getDirection().equals(Direction.LEFT)){
			tankImage = facingLeftImage;
		}
		if (owner.getDirection().equals(Direction.DOWN)){
			tankImage = facingDownImage;
		}
		if (owner.getDirection().equals(Direction.UP)){
			tankImage = facingUpImage;
		}
		return tankImage;
	}
	public int getCurrentAngle(Tank owner){
		if (owner.isDestroyed()){
			return 0;
		}
		
		int angle = 0;
		
		if (owner.getDirection().equals(Direction.RIGHT)){
			angle = 90;
		}
		if (owner.getDirection().equals(Direction.LEFT)){
			angle = 270;
		}
		if (owner.getDirection().equals(Direction.DOWN)){
			angle = 180;
		}
		if (owner.getDirection().equals(Direction.UP)){
			angle = 0;
		}
		return angle;
	}	
	public TankImage(Bitmap facingLeftImage, Bitmap facingRightImage,
			Bitmap facingUpImage, Bitmap facingDownImage, Bitmap destroyedImage) {
		super();
		this.facingLeftImage = facingLeftImage;
		this.facingRightImage = facingRightImage;
		this.facingUpImage = facingUpImage;
		this.facingDownImage = facingDownImage;
		this.destroyedImage = destroyedImage;
	}
	
	public Bitmap getFacingLeftImage() {
		return facingLeftImage;
	}
	public void setFacingLeftImage(Bitmap facingLeftImage) {
		this.facingLeftImage = facingLeftImage;
	}
	public Bitmap getFacingRightImage() {
		return facingRightImage;
	}
	public void setFacingRightImage(Bitmap facingRightImage) {
		this.facingRightImage = facingRightImage;
	}
	public Bitmap getFacingUpImage() {
		return facingUpImage;
	}
	public void setFacingUpImage(Bitmap facingUpImage) {
		this.facingUpImage = facingUpImage;
	}
	public Bitmap getFacingDownImage() {
		return facingDownImage;
	}
	public void setFacingDownImage(Bitmap facingDownImage) {
		this.facingDownImage = facingDownImage;
	}

	public void setDestroyedImage(Bitmap destroyedImage) {
		this.destroyedImage = destroyedImage;
	}

	public Bitmap getDestroyedImage() {
		return destroyedImage;
	}
}
